home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 15 / BBS in a box XV-1.iso / Files / System 7 / M / Moniker 2.0.1.sit / Moniker 2.0.1 ƒ / Source ƒ / Moniker 2.0.1 AE.c next >
Encoding:
C/C++ Source or Header  |  1992-12-20  |  2.4 KB  |  103 lines  |  [TEXT/KAHL]

  1. /* Moniker 2.0.1 */
  2. /* Copyright ©1992 by Michael J. Simms */
  3.  
  4. /* Include the program header. */
  5. #include "Moniker 2.0.1.h"
  6. #include "AppleEvents.h"
  7.  
  8.  
  9. /* Function prototypes. */
  10. OSErr gotRequired(AppleEvent *);
  11. pascal OSErr HandleODOC(AppleEvent *, AppleEvent *, long);
  12. pascal OSErr HandleQUIT(AppleEvent *, AppleEvent *, long);
  13. pascal OSErr HandleOAPP(AppleEvent *, AppleEvent *, long);
  14. pascal OSErr HandlePDOC(AppleEvent *, AppleEvent *, long);
  15.  
  16. /* External decalaration. */
  17. extern    Boolean    gQuitDemand;
  18.  
  19.  
  20. OSErr
  21. gotRequired(AppleEvent *theAppleEvent)
  22. /* Checks for the required number of parameters. */
  23. {
  24.     OSErr        myErr;
  25.     DescType    typeCode;
  26.     Size        actualSize;
  27.  
  28.     myErr=AEGetAttributePtr(theAppleEvent,keyMissedKeywordAttr,typeWildCard,
  29.         &typeCode,NIL,0,&actualSize);
  30.     if (myErr==errAEDescNotFound) myErr=noErr;
  31.     else if (myErr==noErr) myErr=errAEEventNotHandled;
  32.     return(myErr);
  33. }
  34.  
  35.  
  36. pascal OSErr
  37. HandleODOC(AppleEvent *theAppleEvent,AppleEvent *reply,long myRefCon)
  38. /* Handles the OpenDocument Apple Event. */
  39. {
  40.     long        itemsInList,count;
  41.     Size        actualSize;
  42.     OSErr        myErr;
  43.     FSSpec        myFSS;
  44.     DescType    typeCode;
  45.     AEKeyword    theKeyword;
  46.     AEDescList    docList;
  47.  
  48.     if (!(myErr=AEGetParamDesc(theAppleEvent,keyDirectObject,typeAEList,&docList))) {
  49.  
  50.         if (!(myErr=gotRequired(theAppleEvent))) {
  51.  
  52.             if (!(myErr=AECountItems(&docList,&itemsInList))) {
  53.                 /* Make an alias for each one of the documents. */
  54.  
  55.                 /* Get the file(s) information. */
  56.                 for (count=1;count<=itemsInList;count++) {
  57.                     myErr=AEGetNthPtr(&docList,count,typeFSS,&theKeyword,
  58.                         &typeCode,(Ptr)&myFSS,sizeof(FSSpec),&actualSize);
  59.                     if (!myErr) makeAlias(myFSS);
  60.                     else describeError(myErr);
  61.                 }
  62.  
  63.             } else describeError(myErr);
  64.  
  65.         } else describeError(myErr);
  66.  
  67.     } else describeError(myErr);
  68.  
  69.     /* Set 'gQuitDemand' to TRUE (we are done). */
  70.     gQuitDemand=TRUE;
  71.  
  72.     return(myErr);
  73. }
  74.  
  75.  
  76. pascal OSErr
  77. HandleQUIT(AppleEvent *theAppleEvent,AppleEvent *reply,long myRefCon)
  78. /* Handles the QuitApplication Apple Event. */
  79. {
  80.     return(errAEEventNotHandled);
  81. }
  82.  
  83.  
  84. pascal OSErr
  85. HandlePDOC(AppleEvent *theAppleEvent,AppleEvent *reply,long myRefCon)
  86. /* Handles the PrintDocument Apple Event. */
  87. {
  88.     return(errAEEventNotHandled);
  89. }
  90.  
  91.  
  92. pascal OSErr
  93. HandleOAPP(AppleEvent *theAppleEvent,AppleEvent *reply,long myRefCon)
  94. /* Handles the OpenApplication Apple Event. */
  95. {
  96.     /* Show the 'explain' box. */
  97.     showExplainBox();
  98.  
  99.     /* Set 'gQuitDemand' to TRUE (we are done). */
  100.     gQuitDemand=TRUE;
  101.  
  102.     return(noErr);
  103. }